package com.dy.nygl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dy.nygl.mapper.EquipmentMapper;
import com.dy.nygl.pojo.Equipment;
import com.dy.nygl.service.EquipmentService;

@Service("equipmentService")
public class EquipmentServicelmpl implements EquipmentService {

	@Resource(name = "equipmentDao")
	private EquipmentMapper equipmentDao;

	@Override
	public List<Equipment> selectAll() {
		List<Equipment> list = equipmentDao.selectAll();
		return list;
	}

	@Override
	public void update(Equipment equipment) {
		Equipment equipment2 = new Equipment();
		equipment2.setId(equipment.getId());
		equipment2.setEqipName(equipment.getEqipName());
		equipment2.setEqipId(equipment.getEqipId());
		equipment2.setSerial(equipment.getSerial());
		equipment2.setElecRate(equipment.getElecRate());
		equipment2.setElecVol(equipment.getElecVol());
		equipment2.setInstall(equipment.getInstall());
		equipment2.setStatus(equipment.getStatus());
		equipment2.setSwift(equipment.getSwift());
		equipmentDao.updateByPrimaryKeySelective(equipment2);

	}

	@Override
	public void insert(Equipment equipment) {
		Equipment equipment2 = new Equipment();
		equipment2.setId(equipment.getId());
		equipment2.setEqipName(equipment.getEqipName());
		equipment2.setEqipId(equipment.getEqipId());
		equipment2.setSerial(equipment.getSerial());
		equipment2.setElecRate(equipment.getElecRate());
		equipment2.setElecVol(equipment.getElecVol());
		equipment2.setInstall(equipment.getInstall());
		equipment2.setStatus(equipment.getStatus());
		equipment2.setSwift(equipment.getSwift());
		equipmentDao.insert(equipment2);

	}

	@Override
	public List<Equipment> selectEquip(String sect, String search) {
        if(sect.trim().equals("equipId")){
        	List<Equipment> list=equipmentDao.selectByEquipId(search);
        	return list;
        }
        if(sect.trim().equals("equipName")){
        	List<Equipment> list=equipmentDao.selectByEquipName(search);
        	return list;
        }
		return null;
	}

}
